package com.twu.biblioteca;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Thoughtworker
 * Date: 8/22/13
 * Time: 2:57 PM
 * To change this template use File | Settings | File Templates.
 */
public class Main {

    private static void bookSetup(ArrayList<Book> books)
    {
        books.add(new Book("Book 1"));
        books.add(new Book("Book 2"));
    }

    private static void movieSetup(ArrayList<Movie> movies)
    {
        movies.add(new Movie("Godfather", "1972", "Coppola", "9/10"));
        movies.add(new Movie("UHF", "1989", "Levey", "7.5/10"));
        movies.add(new Movie("Up", "2009", "Docter", "10/10"));
        movies.add(new Movie("Goonies", "1985", "Donner", "9/10"));
        movies.add(new Movie("Elysium", "2013", "Blomkamp", "7/10"));
        movies.add(new Movie("District 9", "2009", "Blomkamp", "9/10"));
        movies.add(new Movie("Finding Nemo", "2003", "Unkrich", "8/10"));
        movies.add(new Movie("Children of Men", "2007", "Cuaron", "9/10"));
        movies.add(new Movie("Primer", "2004", "Carruth", "10/10"));
        movies.add(new Movie("Se7en", "1995", "Fincher", "8.5/10"));
        movies.add(new Movie("Cars", "2006", "Lasseter", "5/10"));
        movies.add(new Movie("Fargo", "1996", "Coen", "N/A"));
        movies.add(new Movie("Burn After Reading", "2008", "Coen", "7/10"));
        movies.add(new Movie("Forrest Gump", "1994", "Zemeckis", "7.5/10"));
        movies.add(new Movie("No Country For Old Men", "2007", "Coen", "8.5/10"));

    }

    public static void main(String[] args) throws IOException {
        PrintStream printStream = new PrintStream(System.out);
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));

        Input input = new Input(bufferedReader);
        Output output = new Output(printStream);
        User user1 = new User("111-1111", "password", "Ian", "510-316-1717", "ian.norris.1991@gmail.com");
        HashMap<String, User> users = new HashMap<String, User>();
        users.put(user1.getUsername(), user1);
        UserGetter userGetter = new UserGetter(users, output);
        ArrayList<Book> books = new ArrayList<Book>();
        bookSetup(books);

        BookGetter bookGetter = new BookGetter(output, books, input);
        ArrayList<Movie> movies = new ArrayList<Movie>();
        movieSetup(movies);
        MovieGetter movieGetter = new MovieGetter(movies, output);
        BookReserver bookReserver = new BookReserver(bookGetter, output);
        List<Command> commands = new ArrayList<Command>();
        commands.add(bookGetter);
        commands.add(bookReserver);
        commands.add(userGetter);
        commands.add(movieGetter);
        Library library = new Library(userGetter);

        BibliotecaApp bibliotecaApp = new BibliotecaApp(input, output, commands, library);
        bibliotecaApp.start();

    }
}
